<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import= "java.sql.Statement"%>
<%@page import= "java.sql.Connection"%>
<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
     <body        >
        <form>
       
        <h3 align="center">历史记录</h3>
        <br>
        
        <table border="1" align="center" style="position:relative" width=600 height=200
        cellpadding=0 cellspacing=0>  <!-- 表格透明 -->
            
            <tr>
                <th align="center">事件描述</th>
                <th align="center">发生时间</th> 
            </tr>
        <%
            Connection con=null;
            Statement stmt=null;
            ResultSet rs=null;
            Class.forName("com.mysql.jdbc.Driver");
            String url="jdbc:mysql://localhost:3306/mypet?useUnicode=true&characterEncoding=gbk";
            con=DriverManager.getConnection(url,"root","") ;
            stmt=con.createStatement();
            String sql="select * from history";
            rs=stmt.executeQuery(sql);
            while(rs.next()){
                %>
        <tr>
           <td align="center"><%=rs.getString("description")%></td>
           <td align="center"><%=rs.getString("data")%></td>        
        </tr>
        <%
            }
             rs.close();
             stmt.close();
             con.close();
            %>
      </table>
    </form>
    </body>
</html>
